﻿function RunFilter() {
    document.getElementById("divProcessing").innerHTML = Portal.CMS.Comment.GetProcessingText().value;
    setTimeout("RealRunFilter()", 10);
}


function RealRunFilter() {
    StatusIndex = document.getElementById("drpSelectStatus").selectedIndex;
    StatusValue = document.getElementById("drpSelectStatus").options[StatusIndex].value;
    PageIndex = 0;
    if (document.getElementById("divSelectPage") != null) {
        PageIndex = document.getElementById("divSelectPage").selectedIndex;
    }
    if (PageIndex < 0) PageIndex = 0;
    CommentTypeIndex = document.getElementById("divSelectCommentType").selectedIndex;
    CommentType = document.getElementById("divSelectCommentType").options[CommentTypeIndex].value;
    value = Portal.CMS.Comment.GetHtml(CommentType, StatusValue, PageIndex).value;
    if (value.indexOf("ERROR") != -1) {
        document.getElementById("divProcessing").innerHTML = "";
        alert(value);
        return;
    }
    document.getElementById("divProcessing").innerHTML = "";
    document.getElementById("divCommentContent").innerHTML = value;
}


function ClientDeleteComment(CommentId) {
    if (confirm(Portal.CMS.Comment.GetConfirmMsg().value) == false) {
        return;
    }
    value = Portal.CMS.Comment.ServerSideDeleteComment(CommentId).value;
    if (value.indexOf("ERROR") != -1) {
        alert(value);
        return;
    }
    alert(Portal.CMS.Comment.GetDeleteOkMsg().value);
    RunFilter();
}

function ClientPublishingComment(CommentId) {
    if (confirm(Portal.CMS.Comment.GetConfirmPublishingMsg().value) == false) {
        return;
    }
    retValue = Portal.CMS.Comment.ServerSidePublishing(CommentId).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    alert(retValue);
}

function ClientUnPublishingComment(CommentId) {
    if (confirm(Portal.CMS.Comment.GetConfirmUnPublishingMsg().value) == false) {
        return;
    }
    retValue = Portal.CMS.Comment.ServerSideUnPublishing(CommentId).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    alert(retValue);
}


function ClientSaveComment(CommentId) {
    FullName = document.getElementById("txtWriteCommentFullName").value;
    Email = document.getElementById("txtWriteCommentEmail").value;
    Subject = document.getElementById("txtWriteCommentSubject").value;
    Content = document.getElementById("txtCommentContent").value;
    rValue = Portal.CMS.UpdateComment.ServerSideSaveComment(CommentId, FullName, Email, Subject, Content).value;
    alert(rValue);
}

function ClientUpdateComment(CommentId) {
    Url = Portal.CMS.Comment.ServerSideGetUpdateCommentUrl(CommentId).value;
    window.open(Url, '_blank');
}